<!-- 忘记密码 -->
<template>
	<view class="container">
		<!-- 背景图 -->
		<view class="x-c sign-bg"><image class="logo-bg"  :src="$IMG_URL + '/imgs/logo_bg.png'" mode=""></image></view>
		<!-- titleview -->
		<view class="head-box">
			<u-navbar :is-back="false" :background="navBackground"></u-navbar>
		</view>
		<view class="wrapper">
			<!-- logo -->
			<view class="x-c">
				<image class="logo" src="/static/images/logo.png" mode="widthFix"></image>
				<!-- <image class="logo" :src="sysInfo.logo" mode="widthFix"></image> -->
			</view>
			<view class="tab-box x-f">
				<view class="tab-item x-c">
					<text class="tab-title">忘记密码</text>
					<view class="line-box"><text class="triangle"></text></view>
				</view>
			</view>
			<!-- 表单 -->
			<view class="login-box y-f">
				<view class="input-item x-c">
					<text class="inp-title">手机号</text>
					<input class="inp" v-model="userPhone" type="number" placeholder="请输入手机号" placeholder-class="pl" />
				</view>
				<view class="input-item x-c">
					<text class="inp-title">验证码</text>
					<input class="inp" v-model="code.value" type="text" placeholder="请输入验证码" placeholder-class="pl" />
					<button class="u-reset-button code-btn" :disabled="code.status" @tap="getCode">{{ code.text }}</button>
				</view>
				<view class="input-item x-c">
					<text class="inp-title">新密码</text>
					<input class="inp" password v-model="userPassword" type="text" placeholder="请设置新密码" placeholder-class="pl" />
				</view>
			</view>
			<!-- 登录按钮 -->
			<view class="x-c y-f">
				<button class="coco-btn login-btn  " @tap="restPassword">确认</button>
				
				<view class="tip-box">
					<button class="u-reset-button tip-btn" @tap="jump('/pages/public/login')">返回登录</button>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
import { mapMutations, mapActions, mapState } from 'vuex';

export default {
	data() {
		return {
			navBackground:{
				backgroundColor:'rgba(255,255,255,0)'
			},
			code: {
				text: '获取验证码',
				status: false,
				value: ''
			},
			userPhone: '',
			userPassword: '',
			sysInfo: uni.getStorageSync('sysInfo'),
			initData:{}
		};
	},
	computed: {
		
	},
	onLoad() {},
	methods: {
		...mapActions(['getUserInfo', 'showAuthModal']),
		// 路由跳转
		jump(path, parmas) {
			this.$Router.push({
				path: path,
				query: parmas
			});
		},
		// 重置密码
		restPassword() {
			let that = this;
			that.$http('user.forgotPwd', {
				mobile: that.userPhone,
				password: that.userPassword,
				code: that.code.value
			}).then(res => {
				if (res.code === 1) {
					that.$u.toast(res.msg);
					that.showAuthModal('accountLogin');
					that.jump("/pages/public/login");
				}
			});
		},
		closeAuthModal() {
			this.showAuth = false;
			this.$store.dispatch('showAuthModal', '');
		},
		// 获取短信
		async getCode() {
			let that = this;
			that.code.status = true;
			let countdown = 60;
			that.$http('common.smsSend', {
				mobile: that.userPhone,
				event: 'resetpwd'
			}).then(res => {
				if (res.code === 1) {
					that.code.text = countdown + '秒';
					that.code.status = true;
					let timer = setInterval(() => {
						if (countdown > 0) {
							that.code.text = countdown - 1 + '秒';
							countdown--;
						} else {
							clearInterval(timer);
							that.code.text = '获取验证码';
							that.$set(that.code, 'status', false);
						}
					}, 1000);
				} else {
					that.$set(that.code, 'status', false);
				}
			});
		}
	}
};
</script>

<style lang="scss">
/* x水平排列*/
	.x-f {
		display: flex;
		align-items: center;
	}
	/*x两端且水平居中*/
	.x-bc {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	/*x平分且水平居中*/
	.x-ac {
		display: flex;
		justify-content: space-around;
		align-items: center;
	}
	/*x水平靠上对齐*/
	.x-start {
		display: flex;
		align-items: flex-start;
	}
	/*x水平靠下对齐*/
	.x-end {
		display: flex;
		align-items: flex-end;
	}
	/*上下左右居中*/
	.x-c {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	/*y竖直靠左*/
	.y-start {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
	}
	/*y竖直靠右*/
	.y-end {
		display: flex;
		flex-direction: column;
		align-items: flex-end;
	}
	/*y竖直居中*/
	.y-f {
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	// y竖直两端
	.y-b {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	/*y竖直两端居中*/
	.y-bc {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
	}
	
.container {
	position: relative;
	width: 100%;
	height: 100%;
	// overflow: hidden;
	background: linear-gradient(to bottom, rgba(215, 232, 255, 1) 0%, rgba(241, 247, 255, 1) 50%, rgba(255, 255, 255, 1) 100%);

	// titleview
	.head-box {
		.cuIcon-back {
			font-size: 50rpx !important;
			font-weight: 500;
		}
	}

	// logo
	.logo {
		width: 150rpx;
		height: 150rpx;
		border-radius: 40rpx;
	}
	.sign-bg{
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		z-index: 1;
		pointer-events: none;
	}
	.logo-bg {
		width: 750rpx;
		height: 480rpx;
	}
}

.wrapper {
	position: relative;
	z-index: 90;
	padding-bottom: 40upx;
	padding-top: 96upx;
	
	.tip-box {
		margin-top: 40rpx;
		width: 630rpx;
		line-height:40rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(99, 114, 148, .8);
	
		.tcp-radio {
			 
		}
	
		.tcp {
			text-decoration: underline;
		}
	}

	// 登录选项卡
	.tab-box {
		margin: 60rpx auto 30rpx;
		width: 608rpx;

		.tab-item {
			flex: 1;
			height: 80rpx;
			position: relative;

			.tab-title {
				font-size: 32rpx;
				font-weight: bold;
				color: #102044;
			}

			.line-box {
				position: absolute;
				width: 300rpx;
				height: 4rpx;
				background: #9da9bd;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);

				.triangle {
					position: absolute;
					bottom: 0;
					left: 50%;
					transform: translateX(-50%);
					disply: block;
					width: 0;
					height: 0;
					border-width: 10rpx;
					border-style: solid;
					border-color: transparent transparent #9da9bd transparent;
				}
			}
		}
	}

	// 输入
	.login-box {
		.input-item {
			position: relative;
			height: 108rpx;
			// border-bottom: 1rpx solid rgba(#c1cad9, 0.5);
			width: 608rpx;
			&::after{
				content: ' ';
				position: absolute;
				left: 0;
				right: 0;
				bottom: 0;
				height: 1px;
				background-color: #c1cad9;
				transform: scaleY(.5);
			}
			.inp-title{
				color: #102044;
				font-weight: 500;
				padding-right: 30rpx;
				font-size: 28upx;
			}
			.inp {
				flex: 1;
				height: 100%;
				font-size: 28rpx;
			}

			.pl {
				color: rgba(99, 114, 148, .8);
			}

			.code-btn {
				background: none;
				font-size: 28rpx;
				color: #102044;
			}
		}
	}

	// 登录
	.login-btn {
		width: 630upx;
		height: 80upx;
		border-radius: 40rpx;
		margin-top: 70upx;
		background: linear-gradient(to right, rgba(78,146,252, 1), rgba(77, 146, 240, 1));
		box-shadow: 0px 7rpx 6rpx 0px rgba(78,146,252, 0.22);
		color: #fff;
		font-size: 30upx;
	}

	.tip-box {
		width: 630rpx;

		.tip-btn {
			font-size: 28rpx;
			font-weight: 500;
			text-decoration: underline;
			color: rgba(99, 114, 148, .8);
			background: none;
		}
	}

	// 一键登录按钮
	.wx-logo-box {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: rgba(99, 114, 148, .8);
		margin-top: 60rpx;
		background: none;
		display: block;
		&:hover {
			background: none;
		}
		.auto-login {
			width: 80rpx;
			height: 80rpx;
			overflow: hidden;
			margin-bottom: 10rpx;
		}
	}
}
</style>
